import CGlfw

public class SGApplication {
  var window: SGWindow?

  init() {
    if glfwInit() == 0 {
      print("Failed to initialize GLFW! I'm out!")
      return;
    }

    glfwSetErrorCallback({ error, description in
      //const char* 到 swift String的转换，与String.fromCString(description!)一致（swift 2）
      print("Error: \(String(cString:description!))")
    })

  }

  func createWindow() {
    self.window = SGWindow()
    self.window!.createWindow()
  }

  func run() {
    self.window!.run()
  }

  deinit {
    self.window = nil
    glfwTerminate()
  }

}
